package org.example.design.designmode.combination.coursedemo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author songyafei
 */
public class CoursePackage extends CourseComent{

    private List<CourseComent> items = new ArrayList<>();
    private  String name;
    private  Double price;
    private int levle;

    public CoursePackage(String name, Double price, int levle) {
        this.name = name;
        this.price = price;
        this.levle = levle;
    }

    @Override
    public String getName(CourseComent c) {
       return this.name;
    }

    @Override
    public double getPrice(CourseComent c) {
        return this.price;
    }

    @Override
    public void removeChild(CourseComent c) {
        items.remove(c);
    }

    @Override
    public void addChild(CourseComent c) {
        items.add(c);
    }

    @Override
    public void print() {
        System.out.println(this.name);
        for (CourseComent cc:items) {
            if(this.levle>0){
                for (int j = 0; j < this.levle; j++) {
                    System.out.print("     ");
                }
                for (int s = 0; s < this.levle; s++) {
                    if(s==0){System.out.print("+");}
                    System.out.print("-");
                }
            }

            cc.print();
        }
    }
}
